/**
 * 描述: 渠道标示详情页
 *
 * @author jiafei
 * @since 2021/12/06 11:23
 */
layui.define(['index', 'form', 'table', 'laypage', 'layedit'], function (exports) {
    var $ = layui.$;
    var form = layui.form;
    var layer = layui.layer;
    var table = layui.table;
    var laypage = layui.laypage;
    var layedit = layui.layedit;

    form.render(null, "zmn-form");

    // 提交
    form.on('submit(zmn-form-submit)', function (obj) {
        var data = obj.field;
        var url = "/channel/mark/modify/addEdit.action";

        $.ajax({
            async: false,
            type: "POST", url: url,
            contentType: "application/json", dataType: "json", data: JSON.stringify(data),
            success: function (result) {
                if (result.status == 200) {
                    //提示信息为弹出框形式
                    layer.msg("提交成功");
                    setTimeout(function () {
                        const index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.location.reload();//刷新父页面，注意一定要在关闭当前iframe层之前执行刷新
                        parent.layer.close(index); //再执行关闭
                    }, 1000);
                } else {
                    layer.msg(result.message, {"icon": 2});
                }

            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {

            }
        })

        return false;
    });

    $(document).on('click', '#cancleBtn', function () {
        let index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        parent.layer.close(index);
        }
    )
    //对外暴露的接口
    exports('plat_channel_mark_detail', {});
});
